package com.lzy.controller;

import com.lzy.base.BaseInfoProperties;
import com.lzy.grace.result.GraceJSONResult;
import com.lzy.grace.result.ResponseStatusEnum;
import com.lzy.pojo.Users;
import com.lzy.pojo.bo.ModifyUserBO;
import com.lzy.pojo.bo.NewFriendRequestBO;
import com.lzy.pojo.vo.UsersVO;
import com.lzy.service.FriendRequestService;
import com.lzy.service.UsersService;
import com.lzy.utils.PagedGridResult;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.UUID;


@RestController
@RequestMapping("friendRequest")
@Slf4j
public class FriendRequestController extends BaseInfoProperties {

    @Autowired
    private FriendRequestService friendRequestService;
    @PostMapping("add")
    public GraceJSONResult add(@RequestBody @Valid NewFriendRequestBO newFriendRequestBO){

        friendRequestService.addFriendReQuest(newFriendRequestBO);
        return GraceJSONResult.ok();
    }


    @PostMapping("queryNew")
    public GraceJSONResult queryNew(HttpServletRequest request,
                                    @RequestParam(defaultValue = "1",name = "page")  Integer page,
                                    @RequestParam(defaultValue = "10",name = "pageSize") Integer pageSize){
        String userId = request.getHeader(HEADER_USER_ID);
        PagedGridResult pagedGridResult = friendRequestService.queryNewFriendList(userId,page,pageSize);
        return GraceJSONResult.ok(pagedGridResult);
    }


    @PostMapping("pass")
    public GraceJSONResult pass(String friendRequestId,
                                String friendRemark){

        friendRequestService.passNewFriend(friendRequestId,friendRemark);
        return GraceJSONResult.ok();
    }


}
